<%@page import="java.io.PrintWriter"%>
<%@page import="cn.qidisoft.edu.hzjt.model.Student"%>
<%@ page language="java" pageEncoding="UTF-8" buffer="16kb"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<%@ include file="/module/js.jsp"%>
<%@ include file="/module/orderField.jsp"%>
    <script type="text/javascript" src="${basePath}/js/jquery.Huploadify.js"></script>
    <link href="${basePath}/css/Huploadify.css" rel="stylesheet"></link>
<style>

table label.error {
    margin-left: 5px;
    width: auto;
    display: inline;
    color: red;
}
</style>
</head>


<body>

    <form action="#" name="Form" id="Form" method="post">
       <input type="hidden" name="zyid" id="zyid" value="${zyid}"/>
		<table cellpadding="0" cellspacing="0" border="0" class="table-border" width="80%">
			<tr>
				<td class="table-header" colspan="4">业余团校作业</td>
			</tr>
			<%-- <tr>
				<td class="table-titleTD" style="width: 30%"><font style="color: red;">*</font>团校期数:</td>
				<td class="table-contentTD">${data.dxqs}</td>
			</tr> --%>
			
			<tr>
			         <td class="table-titleTD" style="width: 30%">附件:</td>
					 <td class="table-contentTD" colspan="3">
						   <div id="uploadadd"></div>
					 </td>
			 </tr>
			<tr>
				<td class="table-titleTD" style="width: 30%">创建人:</td>
				<td class="table-contentTD">${xm}</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 30%">备注:</td>
				<td class="table-contentTD" colspan="3"><textarea style="width: 90%;height: 80px;" name="bz" id="bz" placeholder="备注"  maxlength="250" ></textarea></td>
			</tr>
		</table>
	</form>
	
	
	<!-- 操作表格 -->
		<br />
		<table cellpadding="1" cellspacing="1" border="0" align="left">
			<tr>
			    <td><input type="button" id="btnSave" class="inputButton"
					style="text-align: center;" value="保存" /></td>
				<td><input type="button" id="btnSaveContinue" class="inputButton"
					style="text-align: center;" value="保存并新增" /></td>
				<td><input type="button" id="Cancel" class="inputButton"
					style="text-align: center;" value="取消" /></td>
				<td><input type="button" id="returnBut" class="inputButton"
					value="返回" style="text-align: center;" /></td>
			</tr>
		</table>
		
	<script>
	
		
		$(document).ready(function() {
			//返回方法
			function backList(){
				window.location.href = "${basePath}/communityAmateurWorkStudent/index?zyid=${zyid}";
			}
			
			//返回
			$("#returnBut").click(function(){
				backList();
			});
			
			//保存
			$('#btnSave').click(function(){
				var _form=$("#Form").validate();
				if(_form.form()){
					document.Form.action ="${basePath}/communityAmateurWorkStudent/add?action=1";
					document.Form.submit();
				}
			});
			
			// 点击保存并新增
			$("#btnSaveContinue").click(function(){
				var _form=$("#Form").validate();
				if(_form.form()){
					document.Form.action ="${basePath}/communityAmateurWorkStudent/add?action=2";
					document.Form.submit();
				}
			});
			
			//取消
			$("#Cancel").click(function() {
				 window.location.href = "${basePath}/communityAmateurWorkStudent/addInInt?zyid=${zyid}";
		 	});

		});
		
	</script>
<script type="text/javascript">
//图片上传
var file_path = "prefix";
var file_path_one = null;
var fileMap = new Array();
$(function(){
		var up = $('#uploadadd').Huploadify({
			auto:false,
			fileTypeExts:'*.*',
			multi:true,
			formData:{key:123456,key2:'vvvv'},
			fileSizeLimit:99999999999,
			showUploadedPercent:true,
			showUploadedSize:true,
			removeTimeout:9999999,
			uploader : '${basePath}/communityAmateurWorkStudent/source_upload',
			onUploadStart:function(file){
				console.log(file.name+'开始上传');
			},
			onInit:function(obj){
				console.log('初始化');
			},
			onUploadComplete:function(file,data){
				    var fi = $.parseJSON(data);
				    //文件名称
				    var filename = fi.filename;
				    //生成后的文件名
				    var sysFilepath = fi.sysfilepath;
				    //文件路径
				    var filepath = fi.filepath;
				    file_path_one = filename + "," + filepath;
				    file_path = file_path+"|"+filepath;
				    up.filePath=file_path_one;
				    //保存到集合
	                fileMap[file.index]=new Array(file_path_one);
			},
			onCancel:function(file){
				console.log(file.name+'删除成功');
			},
			onClearQueue:function(queueItemCount){
				console.log('有'+queueItemCount+'个文件被删除了');
			},
			onDestroy:function(){
				console.log('destroyed!');
			},
			onSelect:function(file){
				console.log(file.name+'加入上传队列');
			},
			onQueueComplete:function(queueData){
				console.log('队列中的文件全部上传完成',queueData);
			}
		  });	
});

//删除图片 
function deletefile(id){
    	var url = "${basePath}/communityAmateurWorkStudent/deletefile";
		$.ajax({
			type : "POST",
			url : url,
			dataType:"json",
			data:{
				filepath : id
			},
			success : function(data) {
				if(data.success == "0000"){
				    layer.alert("删除数据成功！", {icon: 6});
					var file_name = id.split(",")[0];
					$("#"+file_name+"_hr").parent().parent().remove();
				}else{
					 layer.alert("未写入数据库的文件没有删除！请联系管理员！", {icon: 5});
				}
			}
		})
  } 
</script>



</body>
</html>
